#ifndef _AGV_WHEEL_H
#define _AGV_WHEEL_H

struct agv_wheel {
    unsigned char motor_reverse;// 电机是否反向
    unsigned char direction;    // 轮子前进还是后退
    unsigned short speed_ratio; // 减速比
    unsigned short speed;       // cm/s
    float radius;               // 轮子半径

    struct xp_motor *motor;     // 轮子的电机对象
    
    int (*init)(struct agv_wheel *wheel);
    int (*forward)(struct agv_wheel *wheel);
    int (*backoff)(struct agv_wheel *wheel);
    int (*stop)(struct agv_wheel *wheel);
    int (*set_speed)(struct agv_wheel *wheel, unsigned short speed);     // cm/s
    int (*set_emerg)(struct agv_wheel *wheel, unsigned char emerg);
    int (*get_distance)(struct agv_wheel *wheel, int *distance);
    int (*get_error)(struct agv_wheel *wheel, int *error);
    int (*get_encode)(struct agv_wheel *wheel, int *angle);
    int (*clear_error)(struct agv_wheel *wheel);
};

struct agv_wheels {
    unsigned char reverse;

    struct agv_wheel left_wheel;
    struct agv_wheel right_wheel;
};

//extern int xp_wheel_motorSpeed_set(int line_speed0, int line_speed1);
extern int xp_wheel_set_wheel_speed(float line_speed0, float line_speed1);
extern int xp_agv_wheels_init();
extern int xp_agv_wheel_debug(char *type, char *fun, char *param);

#ifndef NULL
#define NULL ((void *)0)
#endif

#endif
